#include <iostream>

using namespace std;

static bool prime(int64_t n) {
    if (n < 2) {
        return false;
    }
    if (n < 4) {
        return true;
    }
    if (n % 2 == 0) {
        return false;
    }
    for (int64_t i = 3; i * i <= n; i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

static int64_t func(int64_t a, int64_t b) {
    int64_t n = 0;
    while (prime(n * n + a * n + b)) {
        n++;
    }
    return n;
}

int main() {
    int64_t max = 0;
    int64_t product = 0;
    for (int64_t a = -999; a < 1000; a++) {
        for (int64_t b = -1000; b <= 1000; b++) {
            int64_t n = func(a, b);
            if (n > max) {
                max = n;
                product = a * b;
            }
        }
    }
    cout << product << endl;
    return 0;
}